/**
 * 
 */
package cz.cvut.fit.crhonjar.mi.run.hawera.tree.statement;

import cz.cvut.fit.crhonjar.mi.run.hawera.tree.TreeVisitor;
import cz.cvut.fit.crhonjar.mi.run.hawera.tree.expression.ExpressionTree;

/**
 * @author Jarec
 * 
 */
public class ReturnTree extends StatementTree {

	private ExpressionTree expression;

	/**
	 * constructs return tree using expression (can be null)
	 * 
	 * @param expression
	 */
	public ReturnTree(ExpressionTree expression) {
		super();
		this.log.debug("> ReturnTree");
		this.expression = expression;
		this.log.debug("< ReturnTree expression?: {}", expression != null);
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see cz.cvut.fit.crhonjar.mi.run.hawera.tree.TreeVisitorAcceptor#accept(cz
	 *      .cvut.fit.crhonjar.mi.run.hawera.tree.TreeVisitor)
	 */
	@Override
	public void accept(TreeVisitor visitor) {
		visitor.visitReturn(this);

	}

	/**
	 * @return the expression
	 */
	public ExpressionTree getExpression() {
		if (this.log.isDebugEnabled()) {
			this.log.debug(">< getExpression exist?: {}",
					this.expression != null);
		}
		return this.expression;
	}

}
